package com.example.rpapp.assembler;


import com.example.config.util.SecurityUtil;
import com.example.rpclient.dto.AcceptPrizeAddCmd;
import com.example.rpclient.dto.data.AcceptPrizeVo;
import com.example.rpdomain.acceptprize.AcceptPrizeEntity;

import java.time.LocalDateTime;


public class AcceptPrizeAssembler {

    public static AcceptPrizeEntity toEntity(AcceptPrizeAddCmd cmd) {
        AcceptPrizeEntity entity = new AcceptPrizeEntity();
        entity.setRecordId(cmd.getRecordId());
        entity.setPhone(cmd.getPhone());
        entity.setAddress(cmd.getAddress());
        entity.setCreateTime(LocalDateTime.now());
        entity.setCreator(SecurityUtil.getUserName());
        entity.setUpdateTime(LocalDateTime.now());
        entity.setUpdater(SecurityUtil.getUserName());

        return entity;
    }

    public static AcceptPrizeVo toAcceptPrizeVO(AcceptPrizeEntity entity) {
        AcceptPrizeVo acceptPrizeVO = new AcceptPrizeVo();
        acceptPrizeVO.setId(entity.getId());
        acceptPrizeVO.setPhone(entity.getPhone());
        acceptPrizeVO.setAddress(entity.getAddress());
        acceptPrizeVO.setCreateTime(entity.getCreateTime());

        return acceptPrizeVO;
    }
}
